package exercise2;

import java.util.Arrays;
import java.util.Random;

public class Test {

    public static int[] createArray(int size) {
        int[] array = new int[size];
        Random random = new Random();
        for (int i = 0; i < size; i++ ) {
            array[i] = random.nextInt(size + 10000);
        }
        return array;
    }

    public static int[] createOrderArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++ ) {
            array[i] = i;
        }
        return array;
    }

    public static void testQuickSort() {
        int[] array = createOrderArray(50_00);
        int[] copyArray = Arrays.copyOf(array,array.length);
        Sort sort = new Sort();
        long start = System.currentTimeMillis();
        sort.quickSort(copyArray);
        long end = System.currentTimeMillis();
        System.out.println("quickSort: " + (end - start));
    }

    public static void testQuickNorSort() {
        int[] array = createArray(50_00000);
        int[] copyArray = Arrays.copyOf(array,array.length);
        Sort sort = new Sort();
        long start = System.currentTimeMillis();
        sort.quickSortNor(copyArray);
        long end = System.currentTimeMillis();
        System.out.println("quickNorSort: " + (end - start));
    }

    public static void testHeapSort() {
        int[] array = createArray(50_00000);
        int[] copyArray = Arrays.copyOf(array,array.length);
        Sort sort = new Sort();
        long start = System.currentTimeMillis();
        sort.heapSort(copyArray);
        long end = System.currentTimeMillis();
        System.out.println("heapSort: " + (end - start));
    }

    public static void main1(String[] args) {
        testQuickNorSort();
        testHeapSort();
    }
    public static void main(String[] args) {
        int[] array = {12,56,23,45,90,78,55,0};
        Sort sort = new Sort();
        //sort.shellSort(array);
        //sort.selectSort2(array);
        //sort.heapSort(array);
        //sort.quickSortNor(array);
        sort.mergeSort(array);
        System.out.println(Arrays.toString(array));
    }
}
